package com.servlet.request;
/**
 * @author wzm
 * @create 2023-11-04 16:40
 * project_name:web2310
 * @Description
 */

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/req3")
public class RequestServlet3 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //http://localhost:8080/req3?name=zs
        //通过案例了解request（获取请求相关的数据）与response（设置响应的数据）对象的作用

        //获取请求的数据
        String name = request.getParameter("name");

        //设置响应数据
        //设置响应头告诉浏览器内容是什么 编码是什么
        response.setHeader("content-type","text/html;charset=utf-8");

        response.getWriter().write("欢迎您"+name);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("post...");
    }
}
